/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mp.weixin.WXpublic.material;

import java.util.Date;

/**
 * 临时素材对象 微信里面不同素材的操作 对应的属性字段不一样 所以只能这样做
 *
 * @author 王仲秋
 */
public class TempMaterial {

    private MediaType type;
    private String mediaId;
    private Date createdAt;

    public MediaType getType() {
        return type;
    }

    public void setType(MediaType type) {
        this.type = type;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public enum MediaType {
        IMAGE("image", "图片"),
        VOICE("voice", "语音"),
        VIDEO("video", "视频"),
        THUMB("thumb", "缩略图");
        private final String value;
        private final String desc;

        MediaType(String value, String desc) {
            this.value = value;
            this.desc = desc;
        }

        public String getValue() {
            return value;
        }

        public String getDesc() {
            return desc;
        }

        public static MediaType getMeiaByValue(String value) {
            for (MediaType mt : MediaType.values()) {
                if (mt.getValue().equals(value)) {
                    return mt;
                }
            }
            return null;
        }
    }
}
